class BootStrap {

     def init = { servletContext ->

       for(int i = 0; i<20 ; i++){
         Pilot p = new Pilot()
         p.name = i+ " base"
         p.surname = "baz"
         p.nascarId = i*345
            for(int k = 0; k< 20 ; k++){

              RaceResult r = new RaceResult()
              r.placeNumber = Math.round(k + Math.sin(k*1d))
              r.raceName = "Race "+ k
              p.addToScores(r) 

            }
         if(p.save(flush:true))
            println("saved " + p.id)
         else
            println("An error occurred " + p.errors)

       }

     }
     def destroy = {
     }
} 